package com.knife.bbs.business;

import java.util.Iterator;
import java.util.List;

import com.knife.bbs.domain.FilterWords;

/**
 * BBS内容过滤类
 * @author stef_wu
 * @author 大峡
 *
 */
public class ContentFilter implements IFilter{
	private FilterWordsService filterWordsService=new FilterWordsService();
	public Object doFilter(Object obj) {
		String msg=(String)obj;
		/**
		 * 在这里执行过滤操作　
		 */		
		List banWords = filterWordsService.queryFilterWords("1=1");		
		for (Iterator it=banWords.iterator(); it.hasNext();) {
			FilterWords fw = (FilterWords) it.next();			
			if (msg.indexOf(fw.getWord()) != -1) {
				msg=msg.replaceAll(fw.getWord(),"？");
			}
		}				
		return msg;
		
	}

}
